%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 Vincent On. [vincenton001-at-gmail.com]

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

function features = derive_features( features )

idx = length( features(1,:) );
n_tp = length( features(:,1) );

%MSD
features( : , idx + 1 ) = (features(:,3)-features(1,3)).^2 + (features(:,4)-features(1,4)).^2;

%Total Distance Traveled
features( : , idx + 2 ) = features(:,22);


for i = 2 : length(features(:,22))
    features( i, idx + 2 ) = features(i-1,24) + features(i,22);
end

%Total Displacement
temp = pdist( [features(:,4) features(:,3)] );

features( 1, idx + 3 ) = 0;
features( 2 : n_tp, idx + 3 ) = temp( 1 : n_tp - 1 );